package com.applancer.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.applancer.model.FeedModel;
import com.applancer.model.GeneralModel;
import com.applancer.nativecmsflip.R;
import com.squareup.picasso.Picasso;

public class PageFragment extends Fragment {

	protected FeedModel fmodel;
	protected ImageView thumb_id;
	protected TextView title_id;
	protected TextView authorID;

	public static PageFragment newInstance(GeneralModel model) {
		PageFragment f = new PageFragment(model);

		return f;
	}

	public PageFragment(GeneralModel feed) {
		fmodel = (FeedModel) feed;
	}

	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

		View v = inflater
				.inflate(R.layout.adapter_feed_pager, container, false);
		ImageView thumb_id = (ImageView) v.findViewById(R.id.thumb_id_pager);
		TextView title_id = (TextView) v.findViewById(R.id.title_id_pager);
		TextView authorID = (TextView) v.findViewById(R.id.author_id_pager);

		FeedModel feedmodel = (FeedModel) fmodel;

		Picasso.with(getActivity()).load(feedmodel.getUrlImageThumb())
				.placeholder(R.drawable.ic_launcher)
				.error(R.drawable.ic_launcher).fit().centerCrop()
				.into(thumb_id);
		title_id.setText(feedmodel.getTitle());
		authorID.setText(feedmodel.getDate());

		return v;
	}

}
